<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TableCreateProduct extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
// create the table
        $table  =  $this->table('ctmon_product',array('id'=>false,'primary_key'=>['id'],'engine'=>'InnoDB','signed'=>false,'collation'=>'utf8mb4_general_ci','comment'=>'产品表||'));
        $table->addColumn('id','biginteger',array('limit' => 20,'signed'=>false,'identity'=>true,'null'=>false,'comment' => '自增id'))
            ->addColumn('username', 'string',array('limit'  =>  255,'null'=>false,'default'=>'','comment'=>'产品名称'))
            ->addColumn('state', 'boolean',array('limit'  =>  1,'default'=>0,'signed'=>false,'comment'=>'产品状态，0下架，1：上架'))
            ->addColumn('type_name', 'string',array('limit'  =>  255,'null'=>false,'default'=>'','comment'=>'产品类型'))
            ->addColumn('power', 'string',array('limit'  =>  255,'null'=>false,'default'=>'','comment'=>'功率'))
            ->addColumn('application', 'string',array('limit'  =>  255,'null'=>false,'default'=>'','comment'=>'应用'))
            ->addColumn('ca', 'string',array('limit'  =>  255,'null'=>false,'default'=>'','comment'=>'证书'))
            ->addColumn('protocol', 'string',array('limit'  =>  255,'null'=>false,'default'=>'','comment'=>'质保'))
            ->addColumn('cat_id', 'integer',array('limit'  =>  2,'default'=>0,'signed'=>false,'comment'=>'分类id'))
            ->addColumn('sort', 'integer',array('limit'  =>  2,'default'=>0,'signed'=>false,'comment'=>'排序'))
            ->addColumn('is_top', 'integer',array('limit'  =>  2,'default'=>0,'signed'=>false,'comment'=>'置顶'))
            ->addColumn('is_hot', 'integer',array('limit'  =>  2,'default'=>0,'signed'=>false,'comment'=>'热门'))
            ->addColumn('is_best', 'integer',array('limit'  =>  2,'default'=>0,'signed'=>false,'comment'=>'加精'))
            ->addColumn('ver','biginteger',array('limit' => 20,'signed'=>false,'null'=>false,'default' =>0,'comment' => '版本检查'))
            ->addColumn('create_time', 'integer',array('limit'  =>  10,'null'=>false,'signed'=>false,'default'=>0,'comment'=>'创建时间'))
            ->addColumn('update_time', 'integer',array('limit'  =>  10,'null'=>false,'signed'=>false,'default'=>0,'comment'=>'修改时间'))
            ->addColumn('delete_time', 'integer',array('limit'  =>  10,'null'=>false,'signed'=>false,'default'=>0,'comment'=>'删除时间'))
            ->create();
    }
}
